Remove color from the errors
authorStephen Becker IV <github@deathbyescalator.com>
Sat, 27 Feb 2016 18:53:30 +0000 (10:53 -0800)
committerStephen Becker IV <github@deathbyescalator.com>
Sat, 12 Mar 2016 19:37:59 +0000 (11:37 -0800)
I updated the error states to use say_status.
Add text to the empty error
The empty error looked odd with the say_status change.
Update all stderr messages
Switch them to format statements and create a helper for the error
status.

30 files changed:
src/bin/bench.rs
src/bin/test.rs
src/cargo/core/shell.rs
src/cargo/lib.rs
tests/support/mod.rs
tests/test_bad_config.rs
tests/test_bad_manifest_path.rs
tests/test_cargo.rs
tests/test_cargo_build_auth.rs
tests/test_cargo_build_lib.rs
tests/test_cargo_cfg.rs
tests/test_cargo_compile.rs
tests/test_cargo_compile_custom_build.rs
tests/test_cargo_compile_git_deps.rs
tests/test_cargo_compile_path_deps.rs
tests/test_cargo_cross_compile.rs
tests/test_cargo_doc.rs
tests/test_cargo_features.rs
tests/test_cargo_init.rs
tests/test_cargo_install.rs
tests/test_cargo_metadata.rs
tests/test_cargo_new.rs
tests/test_cargo_package.rs
tests/test_cargo_publish.rs
tests/test_cargo_read_manifest.rs
tests/test_cargo_registry.rs
tests/test_cargo_run.rs
tests/test_cargo_rustc.rs
tests/test_cargo_rustdoc.rs
tests/test_cargo_test.rs

index 2dd2399ed691ac9e82835a013e9dd2c5d4e7ceeb..a4591c9112fdf5db5a4954f143c3920df3424c51 100644 (file)
@@ -95,7 +95,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         None => Ok(None),
         Some(err) => {
             Err(match err.exit.as_ref().and_then(|e| e.code()) {
-                Some(i) => CliError::new("", i),
+                Some(i) => CliError::new("bench failed", i),
                 None => CliError::from_error(Human(err), 101)
             })
         }
index c92a3c6c5cd58e8912be8e377013bbff04b3f294..65f82490fb357e9bc021c6b9afa8133d6a17cfbc 100644 (file)
@@ -107,7 +107,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         None => Ok(None),
         Some(err) => {
             Err(match err.exit.as_ref().and_then(|e| e.code()) {
-                Some(i) => CliError::new("", i),
+                Some(i) => CliError::new("test failed", i),
                 None => CliError::from_error(Human(err), 101)
             })
         }
index 3b4c19558123632a748929d6cdf44f72fa6cf383..2dbbc3f04a7abd63561140078c51be5b2bf157c6 100644 (file)
@@ -96,7 +96,7 @@ impl MultiShell {
     }
 
     pub fn error<T: ToString>(&mut self, message: T) -> CargoResult<()> {
-        self.err().say(message, RED)
+        self.err().say_status("error", message.to_string(), RED)
     }
 
     pub fn warn<T: ToString>(&mut self, message: T) -> CargoResult<()> {
index 4590a9cd52bdb002570d6f43fd5ca0017fc40124..40cf87322f940c249322e489b650dec4a8b333f2 100644 (file)
@@ -181,9 +181,15 @@ pub fn shell(verbosity: Verbosity, color_config: ColorConfig) -> MultiShell {
 // For fatal errors, print to stderr;
 // and for others, e.g. docopt version info, print to stdout.
 fn output(err: String, shell: &mut MultiShell, fatal: bool) {
-    let std_shell = if fatal {shell.err()} else {shell.out()};
-    let color = if fatal {RED} else {BLACK};
-    let _ = std_shell.say(err, color);
+    let (std_shell, color, message) = if fatal {
+        (shell.err(), RED, Some("error"))
+    } else {
+        (shell.out(), BLACK, None)
+    };
+    let _ = match message{
+        Some(text) => std_shell.say_status(text, err.to_string(), color),
+        None => std_shell.say(err, color)
+    };
 }
 
 pub fn handle_error(err: CliError, shell: &mut MultiShell) {
@@ -194,7 +200,7 @@ pub fn handle_error(err: CliError, shell: &mut MultiShell) {
 
     let hide = unknown && shell.get_verbose() != Verbose;
     if hide {
-        let _ = shell.err().say("An unknown error occurred", RED);
+        let _ = shell.err().say_status("error", "An unknown error occurred", RED);
     } else {
         output(error.to_string(), shell, fatal);
     }
index ef3ed0d70d2be8b06f85f7283585288a44f6bb92..1135849184a013e2622fb548ee10c03eea037cc8 100644 (file)
@@ -653,6 +653,7 @@ pub fn path2url(p: PathBuf) -> Url {
 
 pub static RUNNING:     &'static str = "     Running";
 pub static COMPILING:   &'static str = "   Compiling";
+pub static ERROR:       &'static str = "       error";
 pub static DOCUMENTING: &'static str = " Documenting";
 pub static FRESH:       &'static str = "       Fresh";
 pub static UPDATING:    &'static str = "    Updating";
index e7838c237e6c2a8421ff41f9df8f95c2c1e2ebdd..32428e41771b68f3ccf5b7b7f22b067426dab187 100644 (file)
@@ -1,4 +1,4 @@
-use support::{project, execs};
+use support::{project, execs, ERROR};
 use support::registry::Package;
 use hamcrest::assert_that;
 
@@ -19,9 +19,11 @@ test!(bad1 {
         "#);
     assert_that(foo.cargo_process("build").arg("-v")
                    .arg("--target=nonexistent-target"),
-                execs().with_status(101).with_stderr("\
-expected table for configuration key `target.nonexistent-target`, but found string in [..]config
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} expected table for configuration key `target.nonexistent-target`, \
+but found string in [..]config
+",
+    error = ERROR)));
 });
 
 test!(bad2 {
@@ -38,8 +40,8 @@ test!(bad2 {
                 proxy = 3.0
         "#);
     assert_that(foo.cargo_process("publish").arg("-v"),
-                execs().with_status(101).with_stderr("\
-Couldn't load Cargo configuration
+                execs().with_status(101).with_stderr(&format!("\
+{error} Couldn't load Cargo configuration
 
 Caused by:
   failed to load TOML configuration from `[..]config`
@@ -52,7 +54,7 @@ Caused by:
 
 Caused by:
   found TOML configuration value of unknown type `float`
-"));
+", error = ERROR)));
 });
 
 test!(bad3 {
@@ -69,10 +71,11 @@ test!(bad3 {
               proxy = true
         "#);
     assert_that(foo.cargo_process("publish").arg("-v"),
-                execs().with_status(101).with_stderr("\
-invalid configuration for key `http.proxy`
+                execs().with_status(101).with_stderr(&format!("\
+{error} invalid configuration for key `http.proxy`
 expected a string, but found a boolean in [..]config
-"));
+",
+    error = ERROR)));
 });
 
 test!(bad4 {
@@ -82,13 +85,14 @@ test!(bad4 {
               name = false
         "#);
     assert_that(foo.cargo_process("new").arg("-v").arg("foo"),
-                execs().with_status(101).with_stderr("\
-Failed to create project `foo` at `[..]`
+                execs().with_status(101).with_stderr(&format!("\
+{error} Failed to create project `foo` at `[..]`
 
 Caused by:
   invalid configuration for key `cargo-new.name`
 expected a string, but found a boolean in [..]config
-"));
+",
+    error = ERROR)));
 });
 
 test!(bad5 {
@@ -102,8 +106,8 @@ test!(bad5 {
     foo.build();
     assert_that(foo.cargo("new")
                    .arg("-v").arg("foo").cwd(&foo.root().join("foo")),
-                execs().with_status(101).with_stderr("\
-Couldn't load Cargo configuration
+                execs().with_status(101).with_stderr(&format!("\
+{error} Couldn't load Cargo configuration
 
 Caused by:
   failed to merge key `foo` between files:
@@ -112,7 +116,8 @@ Caused by:
 
 Caused by:
   expected integer, but found string
-"));
+",
+    error = ERROR)));
 });
 
 test!(bad_cargo_config_jobs {
@@ -129,9 +134,10 @@ test!(bad_cargo_config_jobs {
         jobs = -1
     "#);
     assert_that(foo.cargo_process("build").arg("-v"),
-                execs().with_status(101).with_stderr("\
-build.jobs must be positive, but found -1 in [..]
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} build.jobs must be positive, but found -1 in [..]
+",
+    error = ERROR)));
 });
 
 test!(default_cargo_config_jobs {
@@ -183,8 +189,8 @@ test!(invalid_global_config {
     .file("src/lib.rs", "");
 
     assert_that(foo.cargo_process("build").arg("-v"),
-                execs().with_status(101).with_stderr("\
-Couldn't load Cargo configuration
+                execs().with_status(101).with_stderr(&format!("\
+{error} Couldn't load Cargo configuration
 
 Caused by:
   could not parse TOML configuration in `[..]config`
@@ -193,7 +199,8 @@ Caused by:
   could not parse input as TOML
 [..]config:1:2 expected `=`, but found eof
 
-"));
+",
+    error = ERROR)));
 });
 
 test!(bad_cargo_lock {
@@ -208,12 +215,13 @@ test!(bad_cargo_lock {
     .file("src/lib.rs", "");
 
     assert_that(foo.cargo_process("build").arg("-v"),
-                execs().with_status(101).with_stderr("\
-failed to parse lock file at: [..]Cargo.lock
+                execs().with_status(101).with_stderr(&format!("\
+{error} failed to parse lock file at: [..]Cargo.lock
 
 Caused by:
   expected a section for the key `root`
-"));
+",
+    error = ERROR)));
 });
 
 test!(bad_git_dependency {
@@ -230,15 +238,16 @@ test!(bad_git_dependency {
     .file("src/lib.rs", "");
 
     assert_that(foo.cargo_process("build").arg("-v"),
-                execs().with_status(101).with_stderr("\
-Unable to update file:///
+                execs().with_status(101).with_stderr(&format!("\
+{error} Unable to update file:///
 
 Caused by:
   failed to clone into: [..]
 
 Caused by:
   [[..]] 'file:///' is not a valid local file URI
-"));
+",
+    error = ERROR)));
 });
 
 test!(bad_crate_type {
@@ -276,14 +285,15 @@ test!(malformed_override {
     .file("src/lib.rs", "");
 
     assert_that(foo.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-failed to parse manifest at `[..]`
+                execs().with_status(101).with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   could not parse input as TOML
 Cargo.toml:[..]
 
-"));
+",
+    error = ERROR)));
 });
 
 test!(duplicate_binary_names {
@@ -306,12 +316,13 @@ test!(duplicate_binary_names {
     .file("b.rs", r#"fn main() -> () {}"#);
 
     assert_that(foo.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-failed to parse manifest at `[..]`
+                execs().with_status(101).with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   found duplicate binary name e, but all binary targets must have a unique name
-"));
+",
+    error = ERROR)));
 });
 
 test!(duplicate_example_names {
@@ -334,12 +345,13 @@ test!(duplicate_example_names {
     .file("examples/ex2.rs", r#"fn main () -> () {}"#);
 
     assert_that(foo.cargo_process("build").arg("--example").arg("ex"),
-                execs().with_status(101).with_stderr("\
-failed to parse manifest at `[..]`
+                execs().with_status(101).with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   found duplicate example name ex, but all binary targets must have a unique name
-"));
+",
+    error = ERROR)));
 });
 
 test!(duplicate_bench_names {
@@ -362,12 +374,13 @@ test!(duplicate_bench_names {
     .file("benches/ex2.rs", r#"fn main () {}"#);
 
     assert_that(foo.cargo_process("bench"),
-                execs().with_status(101).with_stderr("\
-failed to parse manifest at `[..]`
+                execs().with_status(101).with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   found duplicate bench name ex, but all binary targets must have a unique name
-"));
+",
+    error = ERROR)));
 });
 
 test!(unused_keys {
index 696dca438ad5ab77105de71f86fe8b242122bcc7..6eb0da1a65d63cd457b5afd9ff58b3ac031b92c2 100644 (file)
@@ -1,4 +1,4 @@
-use support::{project, execs, main_file, basic_bin_manifest};
+use support::{project, execs, main_file, basic_bin_manifest, ERROR};
 use hamcrest::{assert_that};
 
 fn setup() {}
@@ -12,7 +12,9 @@ fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {
                  .arg("--manifest-path").arg(manifest_path_argument)
                  .cwd(p.root().parent().unwrap()),
                 execs().with_status(101)
-                       .with_stderr("the manifest-path must be a path to a Cargo.toml file"));
+                       .with_stderr(&format!("{error} the manifest-path must be a path \
+                                             to a Cargo.toml file",
+                                             error = ERROR)));
 }
 
 #[allow(deprecated)] // connect => join in 1.3
@@ -26,7 +28,8 @@ fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) {
                  .cwd(p.root().parent().unwrap()),
                 execs().with_status(101)
                        .with_stderr(
-                           format!("manifest path `{}` does not exist", expected_path)
+                           format!("{error} manifest path `{}` does not exist",
+                                   expected_path, error = ERROR)
                        ));
 }
 
index 5adce9048267dcf02d8ed391caf4a0d5d06a9efb..7b5b6361297e353b8dbe37b17bb79d0dcfb9c427 100644 (file)
@@ -7,7 +7,7 @@ use std::str;
 
 use cargo_process;
 use support::paths;
-use support::{execs, project, mkdir_recursive, ProjectBuilder};
+use support::{execs, project, mkdir_recursive, ProjectBuilder, ERROR};
 use hamcrest::{assert_that};
 
 fn setup() {
@@ -61,11 +61,12 @@ test!(find_closest_biuld_to_build {
 
     assert_that(pr,
                 execs().with_status(101)
-                       .with_stderr("no such subcommand
+                       .with_stderr(&format!("{error} no such subcommand
 
 <tab>Did you mean `build`?
 
-"));
+",
+error = ERROR)));
 });
 
 // if a subcommand is more than 3 edit distance away, we don't make a suggestion
@@ -83,8 +84,9 @@ test!(find_closest_dont_correct_nonsense {
 
     assert_that(pr,
                 execs().with_status(101)
-                       .with_stderr("no such subcommand
-"));
+                       .with_stderr(&format!("{error} no such subcommand
+",
+error = ERROR)));
 });
 
 test!(override_cargo_home {
index c3cf61f02ba384e325b033c7af52515dcd50de6e..e8e9ac59150be7aa94c3a7b541190aa98e7fa97f 100644 (file)
@@ -6,7 +6,7 @@ use std::thread;
 use bufstream::BufStream;
 use git2;
 
-use support::{project, execs, UPDATING};
+use support::{project, execs, UPDATING, ERROR};
 use support::paths;
 use hamcrest::assert_that;
 
@@ -101,7 +101,7 @@ test!(http_auth_offered {
         addr = addr,
         ))
                       .with_stderr(&format!("\
-Unable to update http://{addr}/foo/bar
+{error} Unable to update http://{addr}/foo/bar
 
 Caused by:
   failed to clone into: [..]
@@ -112,7 +112,8 @@ attempted to find username/password via `credential.helper`, but [..]
 
 To learn more, run the command again with --verbose.
 ",
-        addr = addr)));
+        addr = addr,
+        error = ERROR)));
 
     t.join().ok().unwrap();
 });
@@ -145,7 +146,7 @@ test!(https_something_happens {
         addr = addr,
         ))
                       .with_stderr(&format!("\
-Unable to update https://{addr}/foo/bar
+{error} Unable to update https://{addr}/foo/bar
 
 Caused by:
   failed to clone into: [..]
@@ -154,6 +155,7 @@ Caused by:
   {errmsg}
 ",
         addr = addr,
+        error = ERROR,
         errmsg = if cfg!(windows) {
             "[[..]] failed to send request: [..]\n"
         } else if cfg!(target_os = "macos") {
@@ -196,7 +198,7 @@ test!(ssh_something_happens {
         addr = addr,
         ))
                       .with_stderr(&format!("\
-Unable to update ssh://{addr}/foo/bar
+{error} Unable to update ssh://{addr}/foo/bar
 
 Caused by:
   failed to clone into: [..]
@@ -204,6 +206,7 @@ Caused by:
 Caused by:
   [[..]] Failed to start SSH session: Failed getting banner
 ",
-        addr = addr)));
+        addr = addr,
+        error = ERROR)));
     t.join().ok().unwrap();
 });
index 476d2f14bdfce27c89439e61c70b3c5ede9556f7..c89b53471c8a48a8c8a958de98829559d500ec01 100644 (file)
@@ -1,6 +1,6 @@
 use std::path::MAIN_SEPARATOR as SEP;
 use support::{basic_bin_manifest, execs, project, ProjectBuilder};
-use support::{COMPILING, RUNNING};
+use support::{COMPILING, RUNNING, ERROR};
 use hamcrest::{assert_that};
 
 fn setup() {
@@ -50,7 +50,7 @@ test!(build_with_no_lib {
 
     assert_that(p.cargo_process("build").arg("--lib"),
                 execs().with_status(101)
-                       .with_stderr("no library targets found"));
+                       .with_stderr(&format!("{error} no library targets found", error = ERROR)));
 });
 
 test!(build_with_relative_cargo_home_path {
index 9ac9457dc62a2568afa3f66f32a6b1808e627ab8..dbb2fb5833510d73837aaf74749f686f831ecf4e 100644 (file)
@@ -4,7 +4,7 @@ use std::fmt;
 use cargo::util::{Cfg, CfgExpr};
 use hamcrest::assert_that;
 
-use support::{project, execs, COMPILING, UPDATING, DOWNLOADING};
+use support::{project, execs, COMPILING, UPDATING, DOWNLOADING, ERROR};
 use support::registry::Package;
 
 macro_rules! c {
@@ -235,15 +235,16 @@ test!(bad_target_spec {
         .file("src/lib.rs", "");
 
     assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-failed to parse manifest at `[..]`
+                execs().with_status(101).with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   failed to parse `4` as a cfg expression
 
 Caused by:
   unexpected character in cfg `4`, [..]
-"));
+",
+error = ERROR)));
 });
 
 test!(bad_target_spec2 {
@@ -260,15 +261,16 @@ test!(bad_target_spec2 {
         .file("src/lib.rs", "");
 
     assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-failed to parse manifest at `[..]`
+                execs().with_status(101).with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   failed to parse `foo =` as a cfg expression
 
 Caused by:
   expected a string, found nothing
-"));
+",
+error = ERROR)));
 });
 
 test!(multiple_match_ok {
index 897043e72cbabaad11a10268e6141c61efd42079..731546e6372ea5cfb358a315cfa9f04d6bc7ad94 100644 (file)
@@ -4,7 +4,7 @@ use std::io::prelude::*;
 use tempdir::TempDir;
 
 use support::{project, execs, main_file, basic_bin_manifest};
-use support::{COMPILING, RUNNING, ProjectBuilder};
+use support::{COMPILING, RUNNING, ProjectBuilder, ERROR};
 use hamcrest::{assert_that, existing_file, is_not};
 use support::paths::{CargoPathExt,root};
 use cargo::util::process;
@@ -43,12 +43,13 @@ test!(cargo_compile_with_invalid_manifest {
     assert_that(p.cargo_process("build"),
         execs()
         .with_status(101)
-        .with_stderr("\
-failed to parse manifest at `[..]`
+        .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   no `package` or `project` section found.
-"))
+",
+error = ERROR)))
 });
 
 test!(cargo_compile_with_invalid_manifest2 {
@@ -61,14 +62,15 @@ test!(cargo_compile_with_invalid_manifest2 {
     assert_that(p.cargo_process("build"),
         execs()
         .with_status(101)
-        .with_stderr("\
-failed to parse manifest at `[..]`
+        .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   could not parse input as TOML
 Cargo.toml:3:19-3:20 expected a value
 
-"))
+",
+error = ERROR)))
 });
 
 test!(cargo_compile_with_invalid_manifest3 {
@@ -85,12 +87,13 @@ test!(cargo_compile_with_invalid_manifest3 {
                  .arg("src/Cargo.toml"),
         execs()
         .with_status(101)
-        .with_stderr("\
-failed to parse manifest at `[..]`
+        .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   could not parse input as TOML\n\
-src[..]Cargo.toml:1:5-1:6 expected a value\n\n"))
+src[..]Cargo.toml:1:5-1:6 expected a value\n\n",
+error = ERROR)))
 });
 
 test!(cargo_compile_with_invalid_version {
@@ -105,12 +108,13 @@ test!(cargo_compile_with_invalid_version {
     assert_that(p.cargo_process("build"),
                 execs()
                 .with_status(101)
-                .with_stderr("\
-failed to parse manifest at `[..]`
+                .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   cannot parse '1.0' as a semver for the key `project.version`
-"))
+",
+error = ERROR)))
 
 });
 
@@ -126,12 +130,13 @@ test!(cargo_compile_with_invalid_package_name {
     assert_that(p.cargo_process("build"),
                 execs()
                 .with_status(101)
-                .with_stderr("\
-failed to parse manifest at `[..]`
+                .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   package name cannot be an empty string.
-"))
+",
+error = ERROR)))
 });
 
 test!(cargo_compile_with_invalid_bin_target_name {
@@ -149,12 +154,13 @@ test!(cargo_compile_with_invalid_bin_target_name {
     assert_that(p.cargo_process("build"),
                 execs()
                 .with_status(101)
-                .with_stderr("\
-failed to parse manifest at `[..]`
+                .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   binary target names cannot be empty.
-"))
+",
+error = ERROR)))
 });
 
 test!(cargo_compile_with_forbidden_bin_target_name {
@@ -172,12 +178,13 @@ test!(cargo_compile_with_forbidden_bin_target_name {
     assert_that(p.cargo_process("build"),
                 execs()
                 .with_status(101)
-                .with_stderr("\
-failed to parse manifest at `[..]`
+                .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   the binary target name `build` is forbidden
-"))
+",
+error = ERROR)))
 });
 
 test!(cargo_compile_with_invalid_lib_target_name {
@@ -195,12 +202,13 @@ test!(cargo_compile_with_invalid_lib_target_name {
     assert_that(p.cargo_process("build"),
                 execs()
                 .with_status(101)
-                .with_stderr("\
-failed to parse manifest at `[..]`
+                .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   library target names cannot be empty.
-"))
+",
+error = ERROR)))
 });
 
 test!(cargo_compile_without_manifest {
@@ -209,9 +217,10 @@ test!(cargo_compile_without_manifest {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101)
-                       .with_stderr("\
-could not find `Cargo.toml` in `[..]` or any parent directory
-"));
+                       .with_stderr(&format!("\
+{error} could not find `Cargo.toml` in `[..]` or any parent directory
+",
+error = ERROR)));
 });
 
 test!(cargo_compile_with_invalid_code {
@@ -227,10 +236,10 @@ src[..]foo.rs:1:1: 1:8 error: expected item[..]found `invalid`
 src[..]foo.rs:1 invalid rust code!
              ^~~~~~~
 ")
-        .with_stderr_contains("\
-Could not compile `foo`.
+        .with_stderr_contains(format!("\
+{error} Could not compile `foo`.
 
-To learn more, run the command again with --verbose.\n"));
+To learn more, run the command again with --verbose.\n", error = ERROR)));
     assert_that(&p.root().join("Cargo.lock"), existing_file());
 });
 
@@ -606,10 +615,10 @@ test!(cargo_compile_with_dep_name_mismatch {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(&format!(
-r#"no matching package named `notquitebar` found (required by `foo`)
+r#"{error} no matching package named `notquitebar` found (required by `foo`)
 location searched: {proj_dir}/bar
 version required: *
-"#, proj_dir = p.url())));
+"#, error = ERROR, proj_dir = p.url())));
 });
 
 test!(compile_path_dep_then_change_version {
@@ -642,13 +651,14 @@ test!(compile_path_dep_then_change_version {
     "#).unwrap();
 
     assert_that(p.cargo("build"),
-                execs().with_status(101).with_stderr("\
-no matching package named `bar` found (required by `foo`)
+                execs().with_status(101).with_stderr(&format!("\
+{error} no matching package named `bar` found (required by `foo`)
 location searched: [..]
 version required: = 0.0.1
 versions found: 0.0.2
 consider running `cargo update` to update a path dependency's locked version
-"));
+",
+error = ERROR)));
 });
 
 test!(ignores_carriage_return_in_lockfile {
@@ -846,9 +856,10 @@ test!(self_dependency {
         .file("src/test.rs", "fn main() {}");
     assert_that(p.cargo_process("build"),
                 execs().with_status(101)
-                       .with_stderr("\
-cyclic package dependency: package `test v0.0.0 ([..])` depends on itself
-"));
+                       .with_stderr(&format!("\
+{error} cyclic package dependency: package `test v0.0.0 ([..])` depends on itself
+",
+error = ERROR)));
 });
 
 test!(ignore_broken_symlinks {
@@ -879,12 +890,13 @@ test!(missing_lib_and_bin {
         "#);
     assert_that(p.cargo_process("build"),
                 execs().with_status(101)
-                       .with_stderr("\
-failed to parse manifest at `[..]Cargo.toml`
+                       .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]Cargo.toml`
 
 Caused by:
   no targets specified in the manifest
-  either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present\n"));
+  either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present\n",
+error = ERROR)));
 });
 
 test!(lto_build {
@@ -1463,8 +1475,8 @@ test!(bad_cargo_config {
               this is not valid toml
         "#);
     assert_that(foo.cargo_process("build").arg("-v"),
-                execs().with_status(101).with_stderr("\
-Couldn't load Cargo configuration
+                execs().with_status(101).with_stderr(&format!("\
+{error} Couldn't load Cargo configuration
 
 Caused by:
   could not parse TOML configuration in `[..]`
@@ -1473,7 +1485,8 @@ Caused by:
   could not parse input as TOML
 [..].cargo[..]config:2:20-2:21 expected `=`, but found `i`
 
-"));
+",
+error = ERROR)));
 });
 
 test!(cargo_platform_specific_dependency {
@@ -1686,16 +1699,17 @@ test!(transitive_dependencies_not_available {
 
     assert_that(p.cargo_process("build").arg("-v"),
                 execs().with_status(101)
-                       .with_stderr("\
+                       .with_stderr(format!("\
 [..] can't find crate for `bbbbb`[..]
 [..] extern crate bbbbb; [..]
 [..]
 error: aborting due to previous error
-Could not compile `foo`.
+{error} Could not compile `foo`.
 
 Caused by:
   [..]
-"));
+",
+error = ERROR)));
 });
 
 test!(cyclic_deps_rejected {
@@ -1723,9 +1737,10 @@ test!(cyclic_deps_rejected {
 
     assert_that(p.cargo_process("build").arg("-v"),
                 execs().with_status(101)
-                       .with_stderr("\
-cyclic package dependency: package `foo v0.0.1 ([..])` depends on itself
-"));
+                       .with_stderr(&format!("\
+{error} cyclic package dependency: package `foo v0.0.1 ([..])` depends on itself
+",
+error = ERROR)));
 });
 
 test!(predictable_filenames {
@@ -1799,12 +1814,13 @@ test!(rustc_env_var {
     assert_that(p.cargo("build")
                  .env("RUSTC", "rustc-that-does-not-exist").arg("-v"),
                 execs().with_status(101)
-                       .with_stderr("\
-Could not execute process `rustc-that-does-not-exist -vV` ([..])
+                       .with_stderr(&format!("\
+{error} Could not execute process `rustc-that-does-not-exist -vV` ([..])
 
 Caused by:
 [..]
-"));
+",
+error = ERROR)));
     assert_that(&p.bin("a"), is_not(existing_file()));
 });
 
@@ -2031,12 +2047,12 @@ test!(invalid_spec {
     p.build();
 
     assert_that(p.cargo_process("build").arg("-p").arg("notAValidDep"),
-                execs().with_status(101).with_stderr(
-                    "could not find package matching spec `notAValidDep`".to_string()));
+                execs().with_status(101).with_stderr(&format!(
+                    "{error} could not find package matching spec `notAValidDep`", error = ERROR)));
 
     assert_that(p.cargo_process("build").arg("-p").arg("d1").arg("-p").arg("notAValidDep"),
-                execs().with_status(101).with_stderr(
-                    "could not find package matching spec `notAValidDep`".to_string()));
+                execs().with_status(101).with_stderr(&format!(
+                    "{error} could not find package matching spec `notAValidDep`", error = ERROR)));
 
 });
 
index 7c2ed61035ed0b7eddb168f3064352468ddd8d24..a9c69ce81441c026c20a666f8f28ea8483ce1371 100644 (file)
@@ -2,7 +2,7 @@ use std::fs::{self, File};
 use std::io::prelude::*;
 
 use support::{project, execs};
-use support::{COMPILING, RUNNING, DOCTEST, FRESH, DOCUMENTING};
+use support::{COMPILING, RUNNING, DOCTEST, FRESH, DOCUMENTING, ERROR};
 use support::paths::CargoPathExt;
 use hamcrest::{assert_that, existing_file, existing_dir};
 
@@ -36,10 +36,10 @@ test!(custom_build_script_failed {
 ",
 url = p.url(), compiling = COMPILING, running = RUNNING))
                        .with_stderr(&format!("\
-failed to run custom build command for `foo v0.5.0 ({})`
+{error} failed to run custom build command for `foo v0.5.0 ({})`
 Process didn't exit successfully: `[..]build[..]build-script-build[..]` \
     (exit code: 101)",
-p.url())));
+p.url(), error = ERROR)));
 });
 
 test!(custom_build_env_vars {
@@ -135,9 +135,9 @@ test!(custom_build_script_wrong_rustc_flags {
     assert_that(p.cargo_process("build"),
                 execs().with_status(101)
                        .with_stderr(&format!("\
-Only `-l` and `-L` flags are allowed in build script of `foo v0.5.0 ({})`: \
+{error} Only `-l` and `-L` flags are allowed in build script of `foo v0.5.0 ({})`: \
 `-aaa -bbb`",
-p.url())));
+p.url(), error = ERROR)));
 });
 
 /*
@@ -205,10 +205,11 @@ test!(links_no_build_cmd {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101)
-                       .with_stderr("\
-package `foo v0.5.0 (file://[..])` specifies that it links to `a` but does \
+                       .with_stderr(&format!("\
+{error} package `foo v0.5.0 (file://[..])` specifies that it links to `a` but does \
 not have a custom build script
-"));
+",
+  error = ERROR)));
 });
 
 test!(links_duplicates {
@@ -239,13 +240,14 @@ test!(links_duplicates {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101)
-                       .with_stderr("\
-native library `a` is being linked to by more than one package, and can only be \
+                       .with_stderr(&format!("\
+{error} native library `a` is being linked to by more than one package, and can only be \
 linked to by one package
 
   [..] v0.5.0 (file://[..])
   [..] v0.5.0 (file://[..])
-"));
+",
+  error = ERROR)));
 });
 
 test!(overrides_and_links {
@@ -680,16 +682,17 @@ test!(build_deps_not_for_normal {
 
     assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(&target),
                 execs().with_status(101)
-                       .with_stderr("\
+                       .with_stderr(&format!("\
 [..]lib.rs[..] error: can't find crate for `aaaaa`[..]
 [..]lib.rs[..] extern crate aaaaa;
 [..]           ^~~~~~~~~~~~~~~~~~~
 error: aborting due to previous error
-Could not compile `foo`.
+{error} Could not compile `foo`.
 
 Caused by:
   Process didn't exit successfully: [..]
-"));
+",
+  error = ERROR)));
 });
 
 test!(build_cmd_with_a_build_cmd {
@@ -929,12 +932,13 @@ test!(build_script_only {
         .file("build.rs", r#"fn main() {}"#);
     assert_that(p.cargo_process("build").arg("-v"),
                 execs().with_status(101)
-                       .with_stderr("\
-failed to parse manifest at `[..]`
+                       .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   no targets specified in the manifest
-  either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present"));
+  either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present",
+  error = ERROR)));
 });
 
 test!(shared_dep_with_a_build_script {
index 28f9ac8be95428e91ed59487056960a4c412f4db..4e0ca48710edaa30f942b2813f800ce12e6643c3 100644 (file)
@@ -4,7 +4,7 @@ use std::path::Path;
 use git2;
 
 use support::{git, project, execs, main_file, path2url};
-use support::{COMPILING, UPDATING, RUNNING};
+use support::{COMPILING, UPDATING, RUNNING, ERROR};
 use support::paths::{self, CargoPathExt};
 use hamcrest::{assert_that,existing_file};
 use cargo::util::process;
@@ -381,11 +381,11 @@ test!(cargo_compile_with_short_ssh_git {
         execs()
         .with_stdout("")
         .with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   invalid url `{}`: relative URL without a base
-", url)));
+", url, error = ERROR)));
 });
 
 test!(two_revs_same_deps {
@@ -650,11 +650,12 @@ test!(update_with_shared_deps {
     assert_that(p.cargo("update")
                  .arg("-p").arg("bar")
                  .arg("--precise").arg("0.1.2"),
-                execs().with_status(101).with_stderr("\
-Unable to update [..]
+                execs().with_status(101).with_stderr(&format!("\
+{error} Unable to update [..]
 
 To learn more, run the command again with --verbose.
-"));
+",
+error = ERROR)));
 
     // Specifying a precise rev to the old rev shouldn't actually update
     // anything because we already have the rev in the db.
@@ -1355,14 +1356,15 @@ test!(update_ambiguous {
     assert_that(p.cargo("update")
                  .arg("-p").arg("foo"),
                 execs().with_status(101)
-                       .with_stderr("\
-There are multiple `foo` packages in your project, and the specification `foo` \
+                       .with_stderr(&format!("\
+{error} There are multiple `foo` packages in your project, and the specification `foo` \
 is ambiguous.
 Please re-run this command with `-p <spec>` where `<spec>` is one of the \
 following:
   foo:0.[..].0
   foo:0.[..].0
-"));
+",
+error = ERROR)));
 });
 
 test!(update_one_dep_in_repo_with_many_deps {
index 58dbf43696d5dc0c2b9f1108a4a429982fb56730..15bc1a5f755288d5b0d29fff3f2594344388164a 100644 (file)
@@ -2,7 +2,7 @@ use std::fs::{self, File};
 use std::io::prelude::*;
 
 use support::{project, execs, main_file};
-use support::{COMPILING, RUNNING};
+use support::{COMPILING, RUNNING, ERROR};
 use support::paths::{self, CargoPathExt};
 use hamcrest::{assert_that, existing_file};
 use cargo::util::process;
@@ -510,15 +510,16 @@ test!(error_message_for_missing_manifest {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101)
-                       .with_stderr("\
-Unable to update file://[..]
+                       .with_stderr(&format!("\
+{error} Unable to update file://[..]
 
 Caused by:
   failed to read `[..]bar[..]Cargo.toml`
 
 Caused by:
   [..] (os error [..])
-"));
+",
+error = ERROR)));
 
 });
 
@@ -854,8 +855,8 @@ test!(missing_path_dependency {
     p.build();
     assert_that(p.cargo("build"),
                 execs().with_status(101)
-                       .with_stderr("\
-failed to update path override `[..]../whoa-this-does-not-exist` \
+                       .with_stderr(format!("\
+{error} failed to update path override `[..]../whoa-this-does-not-exist` \
 (defined in `[..]`)
 
 Caused by:
@@ -863,5 +864,5 @@ Caused by:
 
 Caused by:
   [..] (os error [..])
-"));
+", error = ERROR)));
 });
index 8c16a485ab794ee652d0991db492c483a4b20dd1..a2dc833e0e17de8e0cc1e99d17c301ef5e298129 100644 (file)
@@ -1,7 +1,7 @@
 use std::env;
 
 use support::{project, execs, basic_bin_manifest};
-use support::{RUNNING, COMPILING, DOCTEST};
+use support::{RUNNING, COMPILING, DOCTEST, ERROR};
 use hamcrest::{assert_that, existing_file};
 use cargo::util::process;
 
@@ -826,16 +826,16 @@ test!(platform_specific_dependencies_do_not_leak {
 
     assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(&target),
                 execs().with_status(101)
-                       .with_stderr("\
+                       .with_stderr(format!("\
 [..] error: can't find crate for `d2`[..]
 [..] extern crate d2;
 [..]
 error: aborting due to previous error
-Could not compile `d1`.
+{error} Could not compile `d1`.
 
 Caused by:
   [..]
-"));
+", error = ERROR)));
 });
 
 test!(platform_specific_variables_reflected_in_build_scripts {
index 6bc412b437b306a421c917e1f2869673f2a38d49..8da26403fcd367e0d164342c195b6b96750889af 100644 (file)
@@ -2,7 +2,7 @@ use std::str;
 use std::fs;
 
 use support::{project, execs, path2url};
-use support::{COMPILING, DOCUMENTING, RUNNING};
+use support::{COMPILING, DOCUMENTING, RUNNING, ERROR};
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
 
 fn setup() {
@@ -206,10 +206,11 @@ test!(doc_lib_bin_same_name {
 
     assert_that(p.cargo_process("doc"),
                 execs().with_status(101)
-                       .with_stderr("\
-cannot document a package where a library and a binary have the same name. \
+                       .with_stderr(&format!("\
+{error} cannot document a package where a library and a binary have the same name. \
 Consider renaming one or marking the target as `doc = false`
-"));
+",
+error = ERROR)));
 });
 
 test!(doc_dash_p {
index b7f62c2c84f4991abfaa1abdea8233d812aca80c..2c677ae97aebc261152de8f5330524377e598d41 100644 (file)
@@ -2,7 +2,7 @@ use std::fs::File;
 use std::io::prelude::*;
 
 use support::{project, execs};
-use support::{COMPILING, FRESH};
+use support::{COMPILING, FRESH, ERROR};
 use support::paths::CargoPathExt;
 use hamcrest::assert_that;
 
@@ -24,11 +24,12 @@ test!(invalid1 {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   Feature `bar` includes `baz` which is neither a dependency nor another feature
-")));
+",
+error = ERROR)));
 });
 
 test!(invalid2 {
@@ -49,11 +50,12 @@ test!(invalid2 {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   Features and dependencies cannot have the same name: `bar`
-")));
+",
+error = ERROR)));
 });
 
 test!(invalid3 {
@@ -74,12 +76,13 @@ test!(invalid3 {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   Feature `bar` depends on `baz` which is not an optional dependency.
 Consider adding `optional = true` to the dependency
-")));
+",
+error = ERROR)));
 });
 
 test!(invalid4 {
@@ -105,8 +108,9 @@ test!(invalid4 {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(&format!("\
-Package `bar v0.0.1 ([..])` does not have these features: `bar`
-")));
+{error} Package `bar v0.0.1 ([..])` does not have these features: `bar`
+",
+error = ERROR)));
 
     let p = p.file("Cargo.toml", r#"
             [project]
@@ -117,8 +121,9 @@ Package `bar v0.0.1 ([..])` does not have these features: `bar`
 
     assert_that(p.cargo_process("build").arg("--features").arg("test"),
                 execs().with_status(101).with_stderr(&format!("\
-Package `foo v0.0.1 ([..])` does not have these features: `test`
-")));
+{error} Package `foo v0.0.1 ([..])` does not have these features: `test`
+",
+error = ERROR)));
 });
 
 test!(invalid5 {
@@ -137,11 +142,12 @@ test!(invalid5 {
 
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   Dev-dependencies are not allowed to be optional: `bar`
-")));
+",
+error = ERROR)));
 });
 
 test!(invalid6 {
@@ -159,11 +165,12 @@ test!(invalid6 {
 
     assert_that(p.cargo_process("build").arg("--features").arg("foo"),
                 execs().with_status(101).with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   Feature `foo` requires `bar` which is not an optional dependency
-")));
+",
+error = ERROR)));
 });
 
 test!(invalid7 {
@@ -182,11 +189,12 @@ test!(invalid7 {
 
     assert_that(p.cargo_process("build").arg("--features").arg("foo"),
                 execs().with_status(101).with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
   Feature `foo` requires `bar` which is not an optional dependency
-")));
+",
+error = ERROR)));
 });
 
 test!(invalid8 {
@@ -212,8 +220,9 @@ test!(invalid8 {
 
     assert_that(p.cargo_process("build").arg("--features").arg("foo"),
                 execs().with_status(101).with_stderr(&format!("\
-features in dependencies cannot enable features in other dependencies: `foo/bar`
-")));
+{error} features in dependencies cannot enable features in other dependencies: `foo/bar`
+",
+error = ERROR)));
 });
 
 test!(no_feature_doesnt_build {
@@ -321,9 +330,10 @@ test!(cyclic_feature {
         .file("src/main.rs", "");
 
     assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-Cyclic feature dependency: feature `default` depends on itself
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} Cyclic feature dependency: feature `default` depends on itself
+",
+error = ERROR)));
 });
 
 test!(cyclic_feature2 {
@@ -341,9 +351,10 @@ test!(cyclic_feature2 {
         .file("src/main.rs", "");
 
     assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-Cyclic feature dependency: feature `[..]` depends on itself
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} Cyclic feature dependency: feature `[..]` depends on itself
+",
+error = ERROR)));
 });
 
 test!(groups_on_groups_on_groups {
index bc35a0cdbc0d3ad4c2087ffdd5528548b0054df7..5a708dad4c48707d1e31fee878153eadc27209b0 100644 (file)
@@ -2,7 +2,7 @@ use std::fs::{self, File};
 use std::io::prelude::*;
 use std::env;
 use tempdir::TempDir;
-use support::{execs, paths, cargo_dir};
+use support::{execs, paths, cargo_dir, ERROR};
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
 
 use cargo::util::{process, ProcessBuilder};
@@ -49,17 +49,17 @@ test!(simple_bin {
 fn bin_already_exists(explicit: bool, rellocation: &str) {
     let path = paths::root().join("foo");
     fs::create_dir_all(&path.join("src")).unwrap();
-    
+
     let sourcefile_path = path.join(rellocation);
-    
+
     let content = br#"
         fn main() {
             println!("Hello, world 2!");
         }
     "#;
-    
+
     File::create(&sourcefile_path).unwrap().write_all(content).unwrap();
-    
+
     if explicit {
         assert_that(cargo_process("init").arg("--bin").arg("--vcs").arg("none")
                                         .env("USER", "foo").cwd(&path),
@@ -72,7 +72,7 @@ fn bin_already_exists(explicit: bool, rellocation: &str) {
 
     assert_that(&paths::root().join("foo/Cargo.toml"), existing_file());
     assert_that(&paths::root().join("foo/src/lib.rs"), is_not(existing_file()));
-    
+
     // Check that our file is not overwritten
     let mut new_content = Vec::new();
     File::open(&sourcefile_path).unwrap().read_to_end(&mut new_content).unwrap();
@@ -106,29 +106,30 @@ test!(bin_already_exists_implicit_namesrc {
 test!(confused_by_multiple_lib_files {
     let path = paths::root().join("foo");
     fs::create_dir_all(&path.join("src")).unwrap();
-    
+
     let sourcefile_path1 = path.join("src/lib.rs");
-    
+
     File::create(&sourcefile_path1).unwrap().write_all(br#"
         fn qqq () {
             println!("Hello, world 2!");
         }
     "#).unwrap();
-    
+
     let sourcefile_path2 = path.join("lib.rs");
-    
+
     File::create(&sourcefile_path2).unwrap().write_all(br#"
         fn qqq () {
             println!("Hello, world 3!");
         }
     "#).unwrap();
-    
+
     assert_that(cargo_process("init").arg("--vcs").arg("none")
                                     .env("USER", "foo").cwd(&path),
-                execs().with_status(101).with_stderr("\
-cannot have a project with multiple libraries, found both `src/lib.rs` and `lib.rs`
-"));
-    
+                execs().with_status(101).with_stderr(&format!("\
+{error} cannot have a project with multiple libraries, found both `src/lib.rs` and `lib.rs`
+",
+error = ERROR)));
+
     assert_that(&paths::root().join("foo/Cargo.toml"), is_not(existing_file()));
 });
 
@@ -136,54 +137,55 @@ cannot have a project with multiple libraries, found both `src/lib.rs` and `lib.
 test!(multibin_project_name_clash {
     let path = paths::root().join("foo");
     fs::create_dir(&path).unwrap();
-    
+
     let sourcefile_path1 = path.join("foo.rs");
-    
+
     File::create(&sourcefile_path1).unwrap().write_all(br#"
         fn main () {
             println!("Hello, world 2!");
         }
     "#).unwrap();
-    
+
     let sourcefile_path2 = path.join("main.rs");
-    
+
     File::create(&sourcefile_path2).unwrap().write_all(br#"
         fn main () {
             println!("Hello, world 3!");
         }
     "#).unwrap();
-    
+
     assert_that(cargo_process("init").arg("--vcs").arg("none")
                                     .env("USER", "foo").cwd(&path),
-                execs().with_status(101).with_stderr("\
-multiple possible binary sources found:
+                execs().with_status(101).with_stderr(&format!("\
+{error} multiple possible binary sources found:
   main.rs
   foo.rs
 cannot automatically generate Cargo.toml as the main target would be ambiguous
-"));
-                
+",
+error = ERROR)));
+
     assert_that(&paths::root().join("foo/Cargo.toml"), is_not(existing_file()));
 });
 
 fn lib_already_exists(rellocation: &str) {
     let path = paths::root().join("foo");
     fs::create_dir_all(&path.join("src")).unwrap();
-    
+
     let sourcefile_path = path.join(rellocation);
-    
+
     let content = br#"
         pub fn qqq() {}
     "#;
-    
+
     File::create(&sourcefile_path).unwrap().write_all(content).unwrap();
-    
+
     assert_that(cargo_process("init").arg("--vcs").arg("none")
                                     .env("USER", "foo").cwd(&path),
                 execs().with_status(0));
 
     assert_that(&paths::root().join("foo/Cargo.toml"), existing_file());
     assert_that(&paths::root().join("foo/src/main.rs"), is_not(existing_file()));
-    
+
     // Check that our file is not overwritten
     let mut new_content = Vec::new();
     File::open(&sourcefile_path).unwrap().read_to_end(&mut new_content).unwrap();
@@ -228,21 +230,22 @@ test!(invalid_dir_name {
     fs::create_dir_all(&foo).unwrap();
     assert_that(cargo_process("init").cwd(foo.clone())
                                      .env("USER", "foo"),
-                execs().with_status(101).with_stderr("\
-Invalid character `.` in crate name: `foo.bar`
+                execs().with_status(101).with_stderr(&format!("\
+{error} Invalid character `.` in crate name: `foo.bar`
 use --name to override crate name
-"));
+",
+error = ERROR)));
 
     assert_that(&foo.join("Cargo.toml"), is_not(existing_file()));
 });
 
 test!(git_autodetect {
     fs::create_dir(&paths::root().join(".git")).unwrap();
-    
+
     assert_that(cargo_process("init")
                                     .env("USER", "foo"),
                 execs().with_status(0));
-    
+
 
     assert_that(&paths::root().join("Cargo.toml"), existing_file());
     assert_that(&paths::root().join("src/lib.rs"), existing_file());
@@ -253,11 +256,11 @@ test!(git_autodetect {
 
 test!(mercurial_autodetect {
     fs::create_dir(&paths::root().join(".hg")).unwrap();
-    
+
     assert_that(cargo_process("init")
                                     .env("USER", "foo"),
                 execs().with_status(0));
-    
+
 
     assert_that(&paths::root().join("Cargo.toml"), existing_file());
     assert_that(&paths::root().join("src/lib.rs"), existing_file());
@@ -267,19 +270,19 @@ test!(mercurial_autodetect {
 
 test!(gitignore_appended_not_replaced {
     fs::create_dir(&paths::root().join(".git")).unwrap();
-    
+
     File::create(&paths::root().join(".gitignore")).unwrap().write_all(b"qqqqqq\n").unwrap();
-    
+
     assert_that(cargo_process("init")
                                     .env("USER", "foo"),
                 execs().with_status(0));
-    
+
 
     assert_that(&paths::root().join("Cargo.toml"), existing_file());
     assert_that(&paths::root().join("src/lib.rs"), existing_file());
     assert_that(&paths::root().join(".git"), existing_dir());
     assert_that(&paths::root().join(".gitignore"), existing_file());
-    
+
     let mut contents = String::new();
     File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
     assert!(contents.contains(r#"qqqqqq"#));
@@ -287,13 +290,13 @@ test!(gitignore_appended_not_replaced {
 
 test!(cargo_lock_gitignored_if_lib1 {
     fs::create_dir(&paths::root().join(".git")).unwrap();
-    
+
     assert_that(cargo_process("init").arg("--vcs").arg("git")
                                      .env("USER", "foo"),
                 execs().with_status(0));
-    
+
     assert_that(&paths::root().join(".gitignore"), existing_file());
-    
+
     let mut contents = String::new();
     File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
     assert!(contents.contains(r#"Cargo.lock"#));
@@ -301,15 +304,15 @@ test!(cargo_lock_gitignored_if_lib1 {
 
 test!(cargo_lock_gitignored_if_lib2 {
     fs::create_dir(&paths::root().join(".git")).unwrap();
-    
+
     File::create(&paths::root().join("lib.rs")).unwrap().write_all(br#""#).unwrap();
 
     assert_that(cargo_process("init").arg("--vcs").arg("git")
                                      .env("USER", "foo"),
                 execs().with_status(0));
-    
+
     assert_that(&paths::root().join(".gitignore"), existing_file());
-    
+
     let mut contents = String::new();
     File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
     assert!(contents.contains(r#"Cargo.lock"#));
@@ -317,14 +320,14 @@ test!(cargo_lock_gitignored_if_lib2 {
 
 test!(cargo_lock_not_gitignored_if_bin1 {
     fs::create_dir(&paths::root().join(".git")).unwrap();
-    
+
     assert_that(cargo_process("init").arg("--vcs").arg("git")
                                      .arg("--bin")
                                      .env("USER", "foo"),
                 execs().with_status(0));
-    
+
     assert_that(&paths::root().join(".gitignore"), existing_file());
-    
+
     let mut contents = String::new();
     File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
     assert!(!contents.contains(r#"Cargo.lock"#));
@@ -332,15 +335,15 @@ test!(cargo_lock_not_gitignored_if_bin1 {
 
 test!(cargo_lock_not_gitignored_if_bin2 {
     fs::create_dir(&paths::root().join(".git")).unwrap();
-    
+
     File::create(&paths::root().join("main.rs")).unwrap().write_all(br#""#).unwrap();
 
     assert_that(cargo_process("init").arg("--vcs").arg("git")
                                      .env("USER", "foo"),
                 execs().with_status(0));
-    
+
     assert_that(&paths::root().join(".gitignore"), existing_file());
-    
+
     let mut contents = String::new();
     File::open(&paths::root().join(".gitignore")).unwrap().read_to_string(&mut contents).unwrap();
     assert!(!contents.contains(r#"Cargo.lock"#));
@@ -357,20 +360,22 @@ test!(with_argument {
 test!(unknown_flags {
     assert_that(cargo_process("init").arg("foo").arg("--flag"),
                 execs().with_status(1)
-                       .with_stderr("\
-Unknown flag: '--flag'
+                       .with_stderr(&format!("\
+{error} Unknown flag: '--flag'
 
 Usage:
     cargo init [options] [<path>]
     cargo init -h | --help
-"));
+",
+error = ERROR)));
 });
 
 #[cfg(not(windows))]
 test!(no_filename {
     assert_that(cargo_process("init").arg("/"),
                 execs().with_status(101)
-                       .with_stderr("\
-cannot auto-detect project name from path \"/\" ; use --name to override
-"));
+                       .with_stderr(&format!("\
+{error} cannot auto-detect project name from path \"/\" ; use --name to override
+",
+error = ERROR)));
 });
index f4a322f4cd1f4e2985519aaa353abb9740557f83..13d50376df72b60d50d73180205153af7cdd9328 100644 (file)
@@ -8,7 +8,7 @@ use cargo::util::ProcessBuilder;
 use hamcrest::{assert_that, existing_file, is_not, Matcher, MatchResult};
 
 use support::{project, execs};
-use support::{UPDATING, DOWNLOADING, COMPILING, INSTALLING, REMOVING};
+use support::{UPDATING, DOWNLOADING, COMPILING, INSTALLING, REMOVING, ERROR};
 use support::paths;
 use support::registry::Package;
 use support::git;
@@ -105,30 +105,33 @@ test!(pick_max_version {
 test!(missing {
     pkg("foo", "0.0.1");
     assert_that(cargo_process("install").arg("bar"),
-                execs().with_status(101).with_stderr("\
-could not find `bar` in `registry file://[..]`
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} could not find `bar` in `registry file://[..]`
+",
+error = ERROR)));
 });
 
 test!(bad_version {
     pkg("foo", "0.0.1");
     assert_that(cargo_process("install").arg("foo").arg("--vers=0.2.0"),
-                execs().with_status(101).with_stderr("\
-could not find `foo` in `registry file://[..]` with version `0.2.0`
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} could not find `foo` in `registry file://[..]` with version `0.2.0`
+",
+error = ERROR)));
 });
 
 test!(no_crate {
     assert_that(cargo_process("install"),
-                execs().with_status(101).with_stderr("\
-`[..]` is not a crate root; specify a crate to install [..]
+                execs().with_status(101).with_stderr(&format!("\
+{error} `[..]` is not a crate root; specify a crate to install [..]
 
 Caused by:
   failed to read `[..]Cargo.toml`
 
 Caused by:
   [..] (os error [..])
-"));
+",
+error = ERROR)));
 });
 
 test!(install_location_precedence {
@@ -194,9 +197,10 @@ test!(install_path {
                 execs().with_status(0));
     assert_that(cargo_home(), has_installed_exe("foo"));
     assert_that(cargo_process("install").arg("--path").arg(".").cwd(p.root()),
-                execs().with_status(101).with_stderr("\
-binary `foo[..]` already exists in destination as part of `foo v0.1.0 [..]`
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} binary `foo[..]` already exists in destination as part of `foo v0.1.0 [..]`
+",
+error = ERROR)));
 });
 
 test!(multiple_crates_error {
@@ -218,9 +222,10 @@ test!(multiple_crates_error {
     p.build();
 
     assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()),
-                execs().with_status(101).with_stderr("\
-multiple packages with binaries found: bar, foo
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} multiple packages with binaries found: bar, foo
+",
+error = ERROR)));
 });
 
 test!(multiple_crates_select {
@@ -333,9 +338,10 @@ test!(no_binaries_or_examples {
     p.build();
 
     assert_that(cargo_process("install").arg("--path").arg(p.root()),
-                execs().with_status(101).with_stderr("\
-no packages found with binaries or examples
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} no packages found with binaries or examples
+",
+error = ERROR)));
 });
 
 test!(no_binaries {
@@ -351,9 +357,10 @@ test!(no_binaries {
     p.build();
 
     assert_that(cargo_process("install").arg("--path").arg(p.root()).arg("foo"),
-                execs().with_status(101).with_stderr("\
-specified package has no binaries
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} specified package has no binaries
+",
+error = ERROR)));
 });
 
 test!(examples {
@@ -388,9 +395,10 @@ test!(install_twice {
     assert_that(cargo_process("install").arg("--path").arg(p.root()),
                 execs().with_status(0));
     assert_that(cargo_process("install").arg("--path").arg(p.root()),
-                execs().with_status(101).with_stderr("\
-binary `foo[..]` already exists in destination as part of `foo v0.1.0 ([..])`
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} binary `foo[..]` already exists in destination as part of `foo v0.1.0 ([..])`
+",
+error = ERROR)));
 });
 
 test!(compile_failure {
@@ -405,17 +413,18 @@ test!(compile_failure {
     p.build();
 
     assert_that(cargo_process("install").arg("--path").arg(p.root()),
-                execs().with_status(101).with_stderr("\
+                execs().with_status(101).with_stderr(&format!("\
 error: main function not found
 error: aborting due to previous error
-failed to compile `foo v0.1.0 (file://[..])`, intermediate artifacts can be \
+{error} failed to compile `foo v0.1.0 (file://[..])`, intermediate artifacts can be \
     found at `[..]target`
 
 Caused by:
   Could not compile `foo`.
 
 To learn more, run the command again with --verbose.
-"));
+",
+error = ERROR)));
 });
 
 test!(git_repo {
@@ -466,9 +475,10 @@ foo v0.0.1 (registry [..]):
 
 test!(uninstall_pkg_does_not_exist {
     assert_that(cargo_process("uninstall").arg("foo"),
-                execs().with_status(101).with_stderr("\
-package id specification `foo` matched no packages
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} package id specification `foo` matched no packages
+",
+error = ERROR)));
 });
 
 test!(uninstall_bin_does_not_exist {
@@ -477,9 +487,10 @@ test!(uninstall_bin_does_not_exist {
     assert_that(cargo_process("install").arg("foo"),
                 execs().with_status(0));
     assert_that(cargo_process("uninstall").arg("foo").arg("--bin=bar"),
-                execs().with_status(101).with_stderr("\
-binary `bar[..]` not installed as part of `foo v0.0.1 ([..])`
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} binary `bar[..]` not installed as part of `foo v0.0.1 ([..])`
+",
+error = ERROR)));
 });
 
 test!(uninstall_piecemeal {
@@ -514,9 +525,10 @@ test!(uninstall_piecemeal {
     assert_that(cargo_home(), is_not(has_installed_exe("foo")));
 
     assert_that(cargo_process("uninstall").arg("foo"),
-                execs().with_status(101).with_stderr("\
-package id specification `foo` matched no packages
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} package id specification `foo` matched no packages
+",
+error = ERROR)));
 });
 
 test!(subcommand_works_out_of_the_box {
@@ -590,11 +602,12 @@ test!(reports_unsuccessful_subcommand_result {
     assert_that(cargo_process("fail"),
                 execs().with_status(101).with_stderr_contains("\
 thread '<main>' panicked at 'explicit panic', [..]
-").with_stderr_contains("\
-third party subcommand `cargo-fail[..]` exited unsuccessfully
+").with_stderr_contains(format!("\
+{error} third party subcommand `cargo-fail[..]` exited unsuccessfully
 
 To learn more, run the command again with --verbose.
-"));
+",
+error = ERROR)));
 });
 
 test!(git_with_lockfile {
index 86761e3bb0aae1a274f7fac7091c6918e9a4e225..543f357d24183201286cd24db341b2db8f476d77 100644 (file)
@@ -1,6 +1,6 @@
 use hamcrest::assert_that;
 use support::registry::Package;
-use support::{project, execs, basic_bin_manifest, main_file};
+use support::{project, execs, basic_bin_manifest, main_file, ERROR};
 
 
 fn setup() {}
@@ -177,11 +177,12 @@ test!(cargo_metadata_with_invalid_manifest {
             .file("Cargo.toml", "");
 
     assert_that(p.cargo_process("metadata"), execs().with_status(101)
-                                                    .with_stderr("\
-failed to parse manifest at `[..]`
+                                                    .with_stderr(&format!("\
+{error} failed to parse manifest at `[..]`
 
 Caused by:
-  no `package` or `project` section found."))
+  no `package` or `project` section found.",
+  error = ERROR)))
 });
 
 const MANIFEST_OUTPUT: &'static str=
@@ -238,7 +239,9 @@ test!(cargo_metadata_no_deps_path_to_cargo_toml_parent_relative {
                  .arg("--manifest-path").arg("foo")
                  .cwd(p.root().parent().unwrap()),
                 execs().with_status(101)
-                       .with_stderr("the manifest-path must be a path to a Cargo.toml file"));
+                       .with_stderr(&format!("{error} the manifest-path must be \
+                                             a path to a Cargo.toml file",
+                                             error = ERROR)));
 });
 
 test!(cargo_metadata_no_deps_path_to_cargo_toml_parent_absolute {
@@ -250,7 +253,9 @@ test!(cargo_metadata_no_deps_path_to_cargo_toml_parent_absolute {
                  .arg("--manifest-path").arg(p.root())
                  .cwd(p.root().parent().unwrap()),
                 execs().with_status(101)
-                       .with_stderr("the manifest-path must be a path to a Cargo.toml file"));
+                       .with_stderr(&format!("{error} the manifest-path must be \
+                                             a path to a Cargo.toml file",
+                                             error = ERROR)));
 });
 
 test!(cargo_metadata_no_deps_cwd {
@@ -273,5 +278,6 @@ test!(carg_metadata_bad_version {
                  .arg("--format-version").arg("2")
                  .cwd(p.root()),
                 execs().with_status(101)
-    .with_stderr("metadata version 2 not supported, only 1 is currently supported"));
+    .with_stderr(&format!("{error} metadata version 2 not supported, only 1 is currently supported",
+                          error = ERROR)));
 });
index 1fc1d19e8a1a86d741755f139c90262f94c6797f..c3e5db359b40d007c644211c656714eea79ddf2c 100644 (file)
@@ -3,7 +3,7 @@ use std::io::prelude::*;
 use std::env;
 use tempdir::TempDir;
 
-use support::{execs, paths};
+use support::{execs, paths, ERROR};
 use support::paths::CargoPathExt;
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
 
@@ -67,13 +67,14 @@ test!(simple_git {
 test!(no_argument {
     assert_that(cargo_process("new"),
                 execs().with_status(1)
-                       .with_stderr("\
-Invalid arguments.
+                       .with_stderr(&format!("\
+{error} Invalid arguments.
 
 Usage:
     cargo new [options] <path>
     cargo new -h | --help
-"));
+",
+error = ERROR)));
 });
 
 test!(existing {
@@ -81,16 +82,17 @@ test!(existing {
     fs::create_dir(&dst).unwrap();
     assert_that(cargo_process("new").arg("foo"),
                 execs().with_status(101)
-                       .with_stderr(format!("destination `{}` already exists\n",
-                                            dst.display())));
+                       .with_stderr(format!("{error} destination `{}` already exists\n",
+                                            dst.display(), error = ERROR)));
 });
 
 test!(invalid_characters {
     assert_that(cargo_process("new").arg("foo.rs"),
                 execs().with_status(101)
-                       .with_stderr("\
-Invalid character `.` in crate name: `foo.rs`
-use --name to override crate name"));
+                       .with_stderr(&format!("\
+{error} Invalid character `.` in crate name: `foo.rs`
+use --name to override crate name",
+error = ERROR)));
 });
 
 test!(rust_prefix_stripped {
@@ -273,11 +275,12 @@ test!(subpackage_git_with_vcs_arg {
 test!(unknown_flags {
     assert_that(cargo_process("new").arg("foo").arg("--flag"),
                 execs().with_status(1)
-                       .with_stderr("\
-Unknown flag: '--flag'
+                       .with_stderr(&format!("\
+{error} Unknown flag: '--flag'
 
 Usage:
     cargo new [..]
     cargo new [..]
-"));
+",
+error = ERROR)));
 });
index 072519da71123f593860a1059fd11bb081e17dc1..0f4937b4cc0597a4051595d373bf931ab95049ac 100644 (file)
@@ -411,6 +411,8 @@ src[..]main.rs
 
 #[cfg(unix)] // windows doesn't allow these characters in filenames
 test!(package_weird_characters {
+
+    use support::ERROR;
     let p = project("foo")
         .file("Cargo.toml", r#"
             [project]
@@ -424,11 +426,12 @@ test!(package_weird_characters {
         .file("src/:foo", "");
 
     assert_that(p.cargo_process("package"),
-                execs().with_status(101).with_stderr("\
+                execs().with_status(101).with_stderr(format!("\
 warning: [..]
-failed to prepare local package for uploading
+{error} failed to prepare local package for uploading
 
 Caused by:
   cannot package a filename with a special character `:`: src/:foo
-"));
+",
+error = ERROR)));
 });
index c985504b67b28103e0be8b2d66f23883b35934e7..15e33f2b53ec6d362011de66e43d018fbc82c091 100644 (file)
@@ -8,7 +8,7 @@ use tar::Archive;
 use url::Url;
 
 use support::{project, execs};
-use support::{UPDATING, PACKAGING, UPLOADING};
+use support::{UPDATING, PACKAGING, UPLOADING, ERROR};
 use support::paths;
 use support::git::repo;
 
@@ -103,10 +103,11 @@ test!(git_deps {
         .file("src/main.rs", "fn main() {}");
 
     assert_that(p.cargo_process("publish").arg("-v").arg("--no-verify"),
-                execs().with_status(101).with_stderr("\
-all dependencies must come from the same source.
+                execs().with_status(101).with_stderr(&format!("\
+{error} all dependencies must come from the same source.
 dependency `foo` comes from git://path/to/nowhere instead
-"));
+",
+error = ERROR)));
 });
 
 test!(path_dependency_no_version {
@@ -132,10 +133,11 @@ test!(path_dependency_no_version {
         .file("bar/src/lib.rs", "");
 
     assert_that(p.cargo_process("publish"),
-                execs().with_status(101).with_stderr("\
-all path dependencies must have a version specified when publishing.
+                execs().with_status(101).with_stderr(&format!("\
+{error} all path dependencies must have a version specified when publishing.
 dependency `bar` does not specify a version
-"));
+",
+error = ERROR)));
 });
 
 test!(unpublishable_crate {
@@ -152,8 +154,9 @@ test!(unpublishable_crate {
         .file("src/main.rs", "fn main() {}");
 
     assert_that(p.cargo_process("publish"),
-                execs().with_status(101).with_stderr("\
-some crates cannot be published.
+                execs().with_status(101).with_stderr(&format!("\
+{error} some crates cannot be published.
 `foo` is marked as unpublishable
-"));
+",
+error = ERROR)));
 });
index 4dae204584750288f22328b8536ac9ad25942e4c..393fad15ba71e133bb1b3bcaced1ccbcd212211f 100644 (file)
@@ -1,4 +1,4 @@
-use support::{project, execs, main_file, basic_bin_manifest};
+use support::{project, execs, main_file, basic_bin_manifest, ERROR};
 use hamcrest::{assert_that};
 
 fn setup() {}
@@ -58,7 +58,8 @@ test!(cargo_read_manifest_path_to_cargo_toml_parent_relative {
                  .arg("--manifest-path").arg("foo")
                  .cwd(p.root().parent().unwrap()),
                 execs().with_status(101)
-                       .with_stderr("the manifest-path must be a path to a Cargo.toml file"));
+                       .with_stderr(&format!("{error} the manifest-path must be \
+                                             a path to a Cargo.toml file", error = ERROR)));
 });
 
 test!(cargo_read_manifest_path_to_cargo_toml_parent_absolute {
@@ -70,7 +71,8 @@ test!(cargo_read_manifest_path_to_cargo_toml_parent_absolute {
                  .arg("--manifest-path").arg(p.root())
                  .cwd(p.root().parent().unwrap()),
                 execs().with_status(101)
-                       .with_stderr("the manifest-path must be a path to a Cargo.toml file"));
+                       .with_stderr(&format!("{error} the manifest-path must be \
+                                             a path to a Cargo.toml file", error = ERROR)));
 });
 
 test!(cargo_read_manifest_cwd {
index 0274bd8700317e255f02a45f08c8fb8d16aba48b..7596ca2acb87d65bccf985cc8ea1b73128e30056 100644 (file)
@@ -2,7 +2,7 @@ use std::fs::{self, File};
 use std::io::prelude::*;
 
 use support::{project, execs};
-use support::{UPDATING, DOWNLOADING, COMPILING, PACKAGING, VERIFYING, ADDING, REMOVING};
+use support::{UPDATING, DOWNLOADING, COMPILING, PACKAGING, VERIFYING, ADDING, REMOVING, ERROR};
 use support::paths::{self, CargoPathExt};
 use support::registry::{self, Package};
 use support::git;
@@ -100,11 +100,12 @@ test!(nonexistent {
         .file("src/main.rs", "fn main() {}");
 
     assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-no matching package named `nonexistent` found (required by `foo`)
+                execs().with_status(101).with_stderr(&format!("\
+{error} no matching package named `nonexistent` found (required by `foo`)
 location searched: registry file://[..]
 version required: >= 0.0.0
-"));
+",
+error = ERROR)));
 });
 
 test!(wrong_version {
@@ -124,23 +125,25 @@ test!(wrong_version {
     Package::new("foo", "0.0.2").publish();
 
     assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-no matching package named `foo` found (required by `foo`)
+                execs().with_status(101).with_stderr(&format!("\
+{error} no matching package named `foo` found (required by `foo`)
 location searched: registry file://[..]
 version required: >= 1.0.0
 versions found: 0.0.2, 0.0.1
-"));
+",
+error = ERROR)));
 
     Package::new("foo", "0.0.3").publish();
     Package::new("foo", "0.0.4").publish();
 
     assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-no matching package named `foo` found (required by `foo`)
+                execs().with_status(101).with_stderr(&format!("\
+{error} no matching package named `foo` found (required by `foo`)
 location searched: registry file://[..]
 version required: >= 1.0.0
 versions found: 0.0.4, 0.0.3, 0.0.2, ...
-"));
+",
+error = ERROR)));
 });
 
 test!(bad_cksum {
@@ -161,15 +164,16 @@ test!(bad_cksum {
     File::create(&pkg.archive_dst()).unwrap();
 
     assert_that(p.cargo_process("build").arg("-v"),
-                execs().with_status(101).with_stderr("\
-unable to get packages from source
+                execs().with_status(101).with_stderr(&format!("\
+{error} unable to get packages from source
 
 Caused by:
   failed to download package `bad-cksum v0.0.1 (registry file://[..])` from [..]
 
 Caused by:
   failed to verify the checksum of `bad-cksum v0.0.1 (registry file://[..])`
-"));
+",
+error = ERROR)));
 });
 
 test!(update_registry {
@@ -188,11 +192,12 @@ test!(update_registry {
         .file("src/main.rs", "fn main() {}");
 
     assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr("\
-no matching package named `notyet` found (required by `foo`)
+                execs().with_status(101).with_stderr(&format!("\
+{error} no matching package named `notyet` found (required by `foo`)
 location searched: registry file://[..]
 version required: >= 0.0.0
-"));
+",
+error = ERROR)));
 
     Package::new("notyet", "0.0.1").publish();
 
@@ -238,14 +243,15 @@ test!(package_with_path_deps {
     p.build();
 
     assert_that(p.cargo("package").arg("-v"),
-                execs().with_status(101).with_stderr("\
-failed to verify package tarball
+                execs().with_status(101).with_stderr(&format!("\
+{error} failed to verify package tarball
 
 Caused by:
   no matching package named `notyet` found (required by `foo`)
 location searched: registry file://[..]
 version required: ^0.0.1
-"));
+",
+error = ERROR)));
 
     Package::new("notyet", "0.0.1").publish();
 
@@ -385,12 +391,13 @@ test!(relying_on_a_yank_is_bad {
     Package::new("bar", "0.0.1").dep("baz", "=0.0.2").publish();
 
     assert_that(p.cargo("build"),
-                execs().with_status(101).with_stderr("\
-no matching package named `baz` found (required by `bar`)
+                execs().with_status(101).with_stderr(&format!("\
+{error} no matching package named `baz` found (required by `bar`)
 location searched: registry file://[..]
 version required: = 0.0.2
 versions found: 0.0.1
-"));
+",
+error = ERROR)));
 });
 
 test!(yanks_in_lockfiles_are_ok {
@@ -420,11 +427,12 @@ test!(yanks_in_lockfiles_are_ok {
                 execs().with_status(0).with_stdout(""));
 
     assert_that(p.cargo("update"),
-                execs().with_status(101).with_stderr("\
-no matching package named `bar` found (required by `foo`)
+                execs().with_status(101).with_stderr(&format!("\
+{error} no matching package named `bar` found (required by `foo`)
 location searched: registry file://[..]
 version required: *
-"));
+",
+error = ERROR)));
 });
 
 test!(update_with_lockfile_if_packages_missing {
@@ -583,8 +591,8 @@ test!(bad_license_file {
         "#);
     assert_that(p.cargo_process("publish").arg("-v"),
                 execs().with_status(101)
-                       .with_stderr("\
-the license file `foo` does not exist"));
+                       .with_stderr(&format!("\
+{error} the license file `foo` does not exist", error = ERROR)));
 });
 
 test!(updating_a_dep {
index cd37c2ea004cf375cbf0a5bb7d78929cbb23349b..8dffc242ffa31704c3b0aa560b94feac8ab2bb16 100644 (file)
@@ -1,7 +1,7 @@
 use std::path::MAIN_SEPARATOR as SEP;
 
 use support::{project, execs, path2url};
-use support::{COMPILING, RUNNING};
+use support::{COMPILING, RUNNING, ERROR};
 use hamcrest::{assert_that, existing_file};
 
 fn setup() {
@@ -64,10 +64,10 @@ test!(simple_quiet_and_verbose {
         "#);
 
     assert_that(p.cargo_process("run").arg("-q").arg("-v"),
-                execs().with_status(101).with_stderr("\
-cannot set both --verbose and --quiet
-")
-    );
+                execs().with_status(101).with_stderr(&format!("\
+{error} cannot set both --verbose and --quiet
+",
+error = ERROR)));
 });
 
 test!(simple_with_args {
@@ -104,9 +104,9 @@ test!(exit_code {
     assert_that(p.cargo_process("run"),
                 execs().with_status(2)
                        .with_stderr(&format!("\
-Process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
+{error} Process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
 ",
-        )));
+error = ERROR)));
 });
 
 test!(exit_code_verbose {
@@ -124,9 +124,9 @@ test!(exit_code_verbose {
     assert_that(p.cargo_process("run").arg("-v"),
                 execs().with_status(2)
                        .with_stderr(&format!("\
-Process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
+{error} Process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
 ",
-        )));
+error = ERROR)));
 });
 
 test!(no_main_file {
@@ -141,8 +141,8 @@ test!(no_main_file {
 
     assert_that(p.cargo_process("run"),
                 execs().with_status(101)
-                       .with_stderr("a bin target must be available \
-                                     for `cargo run`\n"));
+                       .with_stderr(&format!("{error} a bin target must be available \
+                                     for `cargo run`\n", error = ERROR)));
 });
 
 test!(too_many_bins {
@@ -159,9 +159,9 @@ test!(too_many_bins {
 
     assert_that(p.cargo_process("run"),
                 execs().with_status(101)
-                       .with_stderr("`cargo run` requires that a project only \
+                       .with_stderr(&format!("{error} `cargo run` requires that a project only \
                                      have one executable; use the `--bin` option \
-                                     to specify which one to run\n"));
+                                     to specify which one to run\n", error = ERROR)));
 });
 
 test!(specify_name {
@@ -251,9 +251,10 @@ test!(either_name_or_example {
 
     assert_that(p.cargo_process("run").arg("--bin").arg("a").arg("--example").arg("b"),
                 execs().with_status(101)
-                       .with_stderr("`cargo run` can run at most one \
+                       .with_stderr(&format!("{error} `cargo run` can run at most one \
                                      executable, but multiple were \
-                                     specified"));
+                                     specified",
+                                     error = ERROR)));
 });
 
 test!(one_bin_multiple_examples {
index 2816d92a194292f29f2b7c7c0c028f0dde267bb4..b74b87f2453ba0629b55c0e7f2ae031be6b12f4c 100644 (file)
@@ -1,16 +1,17 @@
 use std::path::MAIN_SEPARATOR as SEP;
 
 use support::{execs, project};
-use support::{COMPILING, RUNNING};
+use support::{COMPILING, RUNNING, ERROR};
 
 use hamcrest::assert_that;
 
 fn setup() {
 }
 
-fn cargo_rustc_error() -> &'static str {
-    "extra arguments to `rustc` can only be passed to one target, consider filtering\n\
-    the package by passing e.g. `--lib` or `--bin NAME` to specify a single target"
+fn cargo_rustc_error() -> String {
+    format!("{error} extra arguments to `rustc` can only be passed to one target, \
+    consider filtering\nthe package by passing e.g. `--lib` or `--bin NAME` to \
+    specify a single target", error = ERROR)
 }
 
 test!(build_lib_for_foo {
@@ -125,7 +126,7 @@ test!(fails_when_trying_to_build_main_and_lib_with_args {
                 .arg("--").arg("-Z").arg("unstable-options"),
                 execs()
                 .with_status(101)
-                .with_stderr(cargo_rustc_error()));
+                .with_stderr(&cargo_rustc_error()));
 });
 
 test!(build_with_args_to_one_of_multiple_binaries {
@@ -185,7 +186,7 @@ test!(fails_with_args_to_all_binaries {
                 .arg("--").arg("-Z").arg("unstable-options"),
                 execs()
                 .with_status(101)
-                .with_stderr(cargo_rustc_error()));
+                .with_stderr(&cargo_rustc_error()));
 });
 
 test!(build_with_args_to_one_of_multiple_tests {
@@ -347,11 +348,11 @@ test!(fail_with_multiple_packages {
 
     assert_that(foo.cargo("rustc").arg("-v").arg("-p").arg("bar")
                                           .arg("-p").arg("baz"),
-                execs().with_status(1).with_stderr("\
-Invalid arguments.
+                execs().with_status(1).with_stderr(format!("\
+{error} Invalid arguments.
 
 Usage:
-    cargo rustc [options] [--] [<opts>...]".to_string()));
+    cargo rustc [options] [--] [<opts>...]", error = ERROR)));
 });
 
 test!(rustc_with_other_profile {
index 8d47bf8973f474453c6f9e70d793483985d3298c..440e0b4f1dd021b6fc6384f0e1f69e6b44490bff 100644 (file)
@@ -1,6 +1,6 @@
 use std::path::MAIN_SEPARATOR as SEP;
 use support::{execs, project};
-use support::{COMPILING, RUNNING, DOCUMENTING};
+use support::{COMPILING, RUNNING, DOCUMENTING, ERROR};
 use hamcrest::{assert_that};
 
 fn setup() {
@@ -167,7 +167,8 @@ test!(rustdoc_same_name_err {
                  .arg("--").arg("--no-defaults"),
                 execs()
                 .with_status(101)
-                .with_stderr("cannot document a package where a library and a \
+                .with_stderr(&format!("{error} cannot document a package where a library and a \
                               binary have the same name. Consider renaming one \
-                              or marking the target as `doc = false`"));
+                              or marking the target as `doc = false`",
+                              error = ERROR)));
 });
index ab5cf5f778ffbbdcec97a7a90a4959c50274b2c0..317743045dbcfde9824c379bada8bdabc6f777b8 100644 (file)
@@ -3,7 +3,7 @@ use std::io::prelude::*;
 use std::str;
 
 use support::{project, execs, basic_bin_manifest, basic_lib_manifest};
-use support::{COMPILING, RUNNING, DOCTEST};
+use support::{COMPILING, RUNNING, DOCTEST, ERROR};
 use support::paths::CargoPathExt;
 use hamcrest::{assert_that, existing_file, is_not};
 use cargo::util::process;
@@ -742,10 +742,11 @@ test!(bin_without_name {
     assert_that(p.cargo_process("test"),
                 execs().with_status(101)
                        .with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
-  binary target bin.name is required")));
+  binary target bin.name is required",
+  error = ERROR)));
 });
 
 test!(bench_without_name {
@@ -786,10 +787,11 @@ test!(bench_without_name {
     assert_that(p.cargo_process("test"),
                 execs().with_status(101)
                        .with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
-  bench target bench.name is required")));
+  bench target bench.name is required",
+    error = ERROR)));
 });
 
 test!(test_without_name {
@@ -829,10 +831,11 @@ test!(test_without_name {
     assert_that(p.cargo_process("test"),
                 execs().with_status(101)
                        .with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
-  test target test.name is required")));
+  test target test.name is required",
+  error = ERROR)));
 });
 
 test!(example_without_name {
@@ -872,10 +875,11 @@ test!(example_without_name {
     assert_that(p.cargo_process("test"),
                 execs().with_status(101)
                        .with_stderr(&format!("\
-failed to parse manifest at `[..]`
+{error} failed to parse manifest at `[..]`
 
 Caused by:
-  example target example.name is required")));
+  example target example.name is required",
+  error = ERROR)));
 });
 
 test!(bin_there_for_integration {
@@ -1599,13 +1603,15 @@ test!(bad_example {
         .file("src/lib.rs", "");
 
     assert_that(p.cargo_process("run").arg("--example").arg("foo"),
-                execs().with_status(101).with_stderr("\
-no example target named `foo`
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} no example target named `foo`
+",
+    error = ERROR)));
     assert_that(p.cargo_process("run").arg("--bin").arg("foo"),
-                execs().with_status(101).with_stderr("\
-no bin target named `foo`
-"));
+                execs().with_status(101).with_stderr(&format!("\
+{error} no bin target named `foo`
+",
+    error = ERROR)));
 });
 
 test!(doctest_feature {